iT邦幫忙

2024 iThome 鐵人賽

DAY 5
0
Software Development

Spring boot 從零到寫出ChatGPT系列 第 5

Spring boot 從零開始 (5) - 來實現你第一個URL

  • 分享至 

  • xImage
  •  

Hello大家好! 昨天有成功啟動了localhost的話,今天我們就來看看怎麼有個正常的url產生吧!

建立一個Class

  • 首先,我們先建立一個Controllerfolder (為甚麼要先建立Controller資料夾就等明後天在跟大家分享)
  • 接著按下右鍵 > 新增Class
  • 我們就命名成 HelloWorld.java
    https://ithelp.ithome.com.tw/upload/images/20240919/20112118pUNGgRIiCu.png

在class上面加上 @RestController

https://ithelp.ithome.com.tw/upload/images/20240919/20112118NHXi1nZsyk.png

新增一個method,並加上 @GetMapping

https://ithelp.ithome.com.tw/upload/images/20240919/20112118ZtoUdtuoOa.png

接著就讓我們啟動Application吧!

https://ithelp.ithome.com.tw/upload/images/20240919/20112118WIZUoXkvcW.png

如果看到 Hello World 出現~~~就代表成功了喔 /images/emoticon/emoticon08.gif

接下來幾天,我們接著介紹一些Spring boot annotation、Spring boot 三層式架構、RESTFul定義、還有一些好用的東西⭐️⭐️⭐️


上一篇
Spring boot 從零開始 (4) - 啟動一個Spring boot專案吧!
下一篇
Spring boot 從零開始 (6) - Spring boot 三層式架構 & 認識Controller和Service
系列文
Spring boot 從零到寫出ChatGPT12
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言